#include "OptionsWidget.h"

OptionsWidget::OptionsWidget(QWidget *parent): QWidget(parent)
{
    QVBoxLayout *layout = new QVBoxLayout;

    qtRenderButton = new QRadioButton("Qt绘图直接渲染");
    qtOpenGLRenderButton = new QRadioButton("OpenGL渲染");
    noneRenderButton = new QRadioButton("没有渲染类型");

    buttonGroup = new QButtonGroup;

    buttonGroup->addButton(qtRenderButton, QT_RENDER);
    buttonGroup->addButton(qtOpenGLRenderButton, QT_OPENGL_RENDER);
    buttonGroup->addButton(noneRenderButton, RENDER_NONE);

    layout->addWidget(qtRenderButton);
    layout->addWidget(qtOpenGLRenderButton);
    layout->addWidget(noneRenderButton);

    setLayout(layout);

    connect(buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
            this, &OptionsWidget::selectionChanged);
}

RENDER_TYPE OptionsWidget::getSelectedRenderType() const
{
    return static_cast<RENDER_TYPE>(buttonGroup->checkedId());
}
